package cms

import (
	"github.com/gogf/gf/v2/frame/g"
	"github.com/gogf/gf/v2/net/ghttp"
	"seawolf-admin-go/internal/app/admin/controller"
	"seawolf-admin-go/internal/request/BaseReq"
)

type cLinksCategory struct {
	*controller.BaseController
}

func NewLinksategoryController(group *ghttp.RouterGroup, defaultVersion string) {
	// 初始化内部变量
	inputReq := &BaseReq.I{}
	c := &cLinksCategory{&controller.BaseController{Req: inputReq}}
	c.New(group, defaultVersion)
}

func (c *cLinksCategory) New(group *ghttp.RouterGroup, defaultVersion string) {
	// 配置表名
	c.Req = &BaseReq.I{
		TableName:          "category",
		InfoIgnoreProperty: "delete_at",
		SoftDeleteField:    "delete_at",
		ListQueryOp: &BaseReq.QueryOp{
			KeyWordLikeFields: []string{
				"cat_name",
			},
			OtherWhere: func(r *ghttp.Request) g.Map {
				return g.Map{
					"type": 4,
				}
			},
		},
		PageQueryOp: &BaseReq.QueryOp{
			KeyWordLikeFields: []string{
				"cat_name",
			},
			OtherWhere: func(r *ghttp.Request) g.Map {
				return g.Map{
					"type": 4,
				}
			},
		},
	}
	// 登录中间件
	// 权限判断中间件
	// 处理初始化方法和结束方法中间件
	group.Middleware(func(r *ghttp.Request) {
		c.Init(r)
		r.Middleware.Next()
		c.Shut(r)
	})
	// 注册基础路由
	controller.RegBase(group, c, nil)
}
